﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Web.UI.Adapters;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace sunt.AJAX.Demo.sunt.UpdataPanel
{
    public class Comment
    {
        public string Content
        {
            get;
            set;
        }
        public string Time
        {
            get;
            set;
        }
    }
    public partial class sunt_UpdataPanel_life : System.Web.UI.Page
    {
        private static List<Comment> Comments;
        protected void Page_Load(object sender, EventArgs e)
        {
            //将Button5定义为引起回发的按钮
            ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(this.Button5);
            ScriptManager.GetCurrent(this).AsyncPostBackTimeout = 3;
            if (!IsPostBack)
            {
                Comments = new System.Collections.Generic.List<Comment>();
                this.BindComments();
            }
        }

        public void BindComments()
        {
            this.Repeater1.DataSource = Comments;
            this.Repeater1.DataBind();
        }
        protected void Button_Click(object sender, EventArgs e)
        {
            Thread.Sleep(3000);

            Button btn = sender as Button;
            this.Label1.Text = string.Format("你点击了{0}按钮",btn.Text);
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            Comment comment = new Comment();
            comment.Content = this.TextBox1.Text;
            comment.Time = DateTime.Now.ToString();

            //Comments.Add(comment);
            this.Repeater1.DataSource = new Comment[] { comment};
            this.Repeater1.DataBind();
            //this.BindComments();
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            int tow = 2;
            int i = 3 / (tow - 2);
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            Thread.Sleep(5000);
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(this).RegisterDataItem(this.UpdatePanel4, DateTime.Now.ToString());
        }
    }
};